package client;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;

import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JEditorPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JCheckBox;
import java.awt.Font;
import java.awt.event.WindowAdapter;

public class TableGUI extends JFrame {

	private JPanel mainPanel;
	private JLabel raiseAmount;
	private int raise;
	private int balance;
	private int sb;
	private int bb;
	private int slot;
	public JCheckBox changeCard0;
	public JCheckBox changeCard1;
	public JCheckBox changeCard2;
	public JCheckBox changeCard3;
	private JPanel player1;
	private JPanel player3;
	private JLabel player3Status;
	private JLabel player3Bet;
	private JLabel player3Balance;
	private JPanel player3Cards;
	private JLabel player3card1;
	private JLabel player3card2;
	private JLabel player3card3;
	private JLabel player3card4;
	private JPanel player4;
	private JLabel player4Status;
	private JLabel player4Bet;
	private JPanel player4Cards;
	private JLabel player4Card1;
	private JLabel player4Card2;
	private JLabel player4Card3;
	private JLabel player4Card4;
	private JLabel player4Balance;
	private JPanel player5;
	private JLabel player5Status;
	private JLabel player5Bet;
	private JPanel player5Cards;
	private JLabel player5Card1;
	private JLabel player5Card2;
	private JLabel player5Card3;
	private JLabel player5Card4;
	private JLabel player5Balance;
	private JPanel tableCenter;
	private JLabel smallBlindValue;
	private JLabel bigBlindValue;
	private JLabel startingBalanceValue;
	private JLabel lastWinnerName;
	private JEditorPane log;
	private JPanel playersBottom;
	private JPanel player2;
	private JLabel player2Status;
	private JLabel player2Bet;
	private JPanel player2Cards;
	private JLabel player2Card1;
	private JLabel player2Card2;
	private JLabel player2Card3;
	private JLabel player2Card4;
	private JLabel player2Balance;
	private JLabel player1Status;
	private JLabel player1Bet;
	private JPanel player1Cards;
	private JLabel player1Card1;
	private JLabel player1Card2;
	private JLabel player1Card3;
	private JLabel player1Card4;
	private JLabel player1Balance;
	private JPanel player6;
	private JLabel player6Status;
	private JLabel player6Bet;
	private JPanel player6Cards;
	private JLabel player6Card1;
	private JLabel player6Card2;
	private JLabel player6Card3;
	private JLabel player6Card4;
	private JLabel player6Balance;
	private JButton foldJButton;
	private JButton checkJButton;
	private JButton callJButton;
	private JButton raiseJButton;
	private JButton allInJButton;
	private JButton zeroBetJButton;
	private JButton firstBetJButton;
	private JButton secondBetJButton;
	private JButton thirdBetJButton;
	private JButton changeCards;
	private JLabel userBalance;
	private JLabel totalPot;
	private JLabel shortInformationFromServer;
	private JLabel yourBet;

	/**
	 * Create the frame.
	 */
	public TableGUI(int nsb, int nbb, int nbalance, int nslot) {
		addWindowListener( new ClientWindowAdapter() );
		raise = 0;
		this.balance = nbalance;
		this.sb = nsb;
		this.bb = nbb;
		this.slot = nslot;
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 903, 646);
		mainPanel = new JPanel();
		mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(mainPanel);
		mainPanel.setLayout(null);
		
		JPanel driver = new JPanel();
		driver.setBounds(0, 483, 885, 116);
		mainPanel.add(driver);
		driver.setLayout(new GridLayout(4, 0, 0, 0));
		
		JPanel moneyStuff = new JPanel();
		driver.add(moneyStuff);
		moneyStuff.setLayout(new GridLayout(0, 3, 0, 0));
		
		userBalance = new JLabel("Cash: $0.00");
		userBalance.setHorizontalAlignment(SwingConstants.LEFT);
		moneyStuff.add(userBalance);
		
		totalPot = new JLabel("Pot: $0.00");
		totalPot.setHorizontalAlignment(SwingConstants.CENTER);
		moneyStuff.add(totalPot);
		
		yourBet = new JLabel("Your bet: $0.00");
		moneyStuff.add(yourBet);
		yourBet.setHorizontalAlignment(SwingConstants.RIGHT);
		
		JPanel informations = new JPanel();
		driver.add(informations);
		informations.setLayout(null);
		
		shortInformationFromServer = new JLabel("Not your turn yet. Keep calm and think it out");
		shortInformationFromServer.setBounds(0, 0, 565, 29);
		informations.add(shortInformationFromServer);
		
		raiseAmount = new JLabel("Raise: $0.00");
		raiseAmount.setBounds(590, 0, 295, 29);
		informations.add(raiseAmount);
		raiseAmount.setHorizontalAlignment(SwingConstants.RIGHT);
		
		JPanel actions = new JPanel();
		driver.add(actions);
		actions.setLayout(new GridLayout(1, 5, 0, 0));
		
		foldJButton = new JButton("Fold");
		foldJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Client.clientThread.getOutput().println( "F" );
				bidTimeOver();
			}
		});
		actions.add(foldJButton);
		
		checkJButton = new JButton("Check");
		checkJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Client.clientThread.getOutput().println( "H" );
				bidTimeOver();
			}
		});
		actions.add(checkJButton);
		
		callJButton = new JButton("Call");
		callJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Client.clientThread.getOutput().println( "C" );
				bidTimeOver();
			}
		});
		actions.add(callJButton);
		
		raiseJButton = new JButton("Raise");
		raiseJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Client.clientThread.getOutput().println( "R" + Client.tableGUI.raiseAmount.getText().substring( 8 ) );
				bidTimeOver();
			}
		});
		actions.add(raiseJButton);
		
		allInJButton = new JButton("All in");
		allInJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Client.tableGUI.raise = Client.tableGUI.balance;
				Client.tableGUI.raiseAmount.setText("Raise: $" + Client.tableGUI.raise);
			}
		});
		actions.add(allInJButton);
		
		JPanel actions2 = new JPanel();
		driver.add(actions2);
		actions2.setLayout(new GridLayout(1, 5, 0, 0));
		
		zeroBetJButton = new JButton("$0");
		zeroBetJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Client.tableGUI.raise = 0;
				Client.tableGUI.raiseAmount.setText("Raise: $0");
			}
		});
		actions2.add(zeroBetJButton);
		
		firstBetJButton = new JButton("$25");
		firstBetJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (raise+25<balance){
					Client.tableGUI.raise += 25;
					Client.tableGUI.raiseAmount.setText("Raise: $" + Client.tableGUI.raise);
				}else{
					Client.tableGUI.raise = Client.tableGUI.balance;
					Client.tableGUI.raiseAmount.setText("Raise: $" + Client.tableGUI.raise);
				}
					
			}
		});
		actions2.add(firstBetJButton);
		
		secondBetJButton = new JButton("$50");
		secondBetJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(raise+50<balance){
					Client.tableGUI.raise += 50;
					Client.tableGUI.raiseAmount.setText("Raise: $" + Client.tableGUI.raise);
				}else{
					Client.tableGUI.raise = Client.tableGUI.balance;
					Client.tableGUI.raiseAmount.setText("Raise: $" + Client.tableGUI.raise);
				}
			}
		});
		actions2.add(secondBetJButton);
		
		thirdBetJButton = new JButton("$100");
		thirdBetJButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(raise+100<balance){
					Client.tableGUI.raise += 100;
					Client.tableGUI.raiseAmount.setText("Raise: $" + Client.tableGUI.raise);
				}else{
					Client.tableGUI.raise = Client.tableGUI.balance;
					Client.tableGUI.raiseAmount.setText("Raise: $" + Client.tableGUI.raise);
				}
			}
		});
		actions2.add(thirdBetJButton);
		
		changeCards = new JButton("Change cards");
		changeCards.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String request = "";
				if (Client.tableGUI.changeCard0.isSelected()){
					request += "0";
				}
				if (Client.tableGUI.changeCard1.isSelected()){
					request += "1";
				}
				if (Client.tableGUI.changeCard2.isSelected()){
					request += "2";
				}
				if (Client.tableGUI.changeCard3.isSelected()){
					request += "3";
				}
				if (request.equals("")){
					Client.clientThread.getOutput().println( "-1" );
				}
				else{
					Client.clientThread.getOutput().println( request );
				}
				changeCardsTimeOver();
			}
		});
		actions2.add(changeCards);
		
		JPanel table = new JPanel();
		table.setBounds(0, 24, 885, 459);
		mainPanel.add(table);
		table.setLayout(new GridLayout(0, 1, 0, 0));
		
		JPanel playersTOP = new JPanel();
		table.add(playersTOP);
		playersTOP.setLayout(new GridLayout(1, 3, 0, 0));
		
		player3 = new JPanel();
		player3.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		playersTOP.add(player3);
		player3.setLayout(null);
		
		player3Status = new JLabel("IsDealer/SmallBlind/BigBlind");
		player3Status.setBounds(10, 0, 285, 29);
		player3.add(player3Status);
		
		player3Bet = new JLabel("Current bet: $0.00");
		player3Bet.setBounds(12, 124, 136, 29);
		player3.add(player3Bet);
		
		player3Balance = new JLabel("Balance: $0.00");
		player3Balance.setHorizontalAlignment(SwingConstants.RIGHT);
		player3Balance.setBounds(138, 124, 145, 29);
		player3.add(player3Balance);
		
		player3Cards = new JPanel();
		player3Cards.setBounds(10, 29, 273, 92);
		player3.add(player3Cards);
		player3Cards.setLayout(new GridLayout(1, 4, 2, 2));
		
		player3card1 = new JLabel("First card");
		player3Cards.add(player3card1);
		
		player3card2 = new JLabel("Second Card");
		player3Cards.add(player3card2);
		
		player3card3 = new JLabel("Third Card");
		player3Cards.add(player3card3);
		
		player3card4 = new JLabel("Fourth Card");
		player3Cards.add(player3card4);
		
		player4 = new JPanel();
		player4.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		playersTOP.add(player4);
		player4.setLayout(null);
		
		player4Status = new JLabel("IsDealer/SmallBlind/BigBlind");
		player4Status.setBounds(12, 0, 283, 29);
		player4.add(player4Status);
		
		player4Bet = new JLabel("Current bet: $0.00");
		player4Bet.setBounds(0, 124, 148, 29);
		player4.add(player4Bet);
		
		player4Cards = new JPanel();
		player4Cards.setBounds(10, 30, 273, 91);
		player4.add(player4Cards);
		player4Cards.setLayout(new GridLayout(1, 4, 0, 0));
		
		player4Card1 = new JLabel("First Card");
		player4Cards.add(player4Card1);
		
		player4Card2 = new JLabel("Second Card");
		player4Cards.add(player4Card2);
		
		player4Card3 = new JLabel("Third Card");
		player4Cards.add(player4Card3);
		
		player4Card4 = new JLabel("Fourth Card");
		player4Cards.add(player4Card4);
		
		player4Balance = new JLabel("Balance: $0.00");
		player4Balance.setHorizontalAlignment(SwingConstants.RIGHT);
		player4Balance.setBounds(139, 124, 144, 29);
		player4.add(player4Balance);
		
		player5 = new JPanel();
		player5.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		playersTOP.add(player5);
		player5.setLayout(null);
		
		player5Status = new JLabel("IsDealer/SmallBlind/BigBlind");
		player5Status.setBounds(12, 0, 283, 29);
		player5.add(player5Status);
		
		player5Bet = new JLabel("Current bet: $0.00");
		player5Bet.setBounds(12, 124, 136, 29);
		player5.add(player5Bet);
		
		player5Cards = new JPanel();
		player5Cards.setBounds(10, 30, 273, 91);
		player5.add(player5Cards);
		player5Cards.setLayout(new GridLayout(1, 4, 0, 0));
		
		player5Card1 = new JLabel("First Card");
		player5Cards.add(player5Card1);
		
		player5Card2 = new JLabel("Second Card");
		player5Cards.add(player5Card2);
		
		player5Card3 = new JLabel("Third Card");
		player5Cards.add(player5Card3);
		
		player5Card4 = new JLabel("Fourth Card");
		player5Cards.add(player5Card4);
		
		player5Balance = new JLabel("Balance: $0.00");
		player5Balance.setHorizontalAlignment(SwingConstants.RIGHT);
		player5Balance.setBounds(138, 124, 145, 29);
		player5.add(player5Balance);
		
		tableCenter = new JPanel();
		table.add(tableCenter);
		tableCenter.setLayout(null);
		
		smallBlindValue = new JLabel("SB: $" + this.sb);
		smallBlindValue.setBounds(257, 0, 241, 16);
		tableCenter.add(smallBlindValue);
		
		bigBlindValue = new JLabel("BB: $" + this.bb);
		bigBlindValue.setBounds(257, 13, 241, 16);
		tableCenter.add(bigBlindValue);
		
		startingBalanceValue = new JLabel("Starting balance: $" + this.balance);
		startingBalanceValue.setBounds(257, 27, 241, 16);
		tableCenter.add(startingBalanceValue);
		
		lastWinnerName = new JLabel("Last winner:");
		lastWinnerName.setBounds(257, 42, 241, 16);
		tableCenter.add(lastWinnerName);
		
		log = new JEditorPane();
		log.setText("Log");
		log.setBounds(0, 0, 250, 153);
		tableCenter.add(log);
		
		changeCard0 = new JCheckBox("Change card 1");
		changeCard0.setBounds(764, 9, 113, 25);
		tableCenter.add(changeCard0);
		
		changeCard1 = new JCheckBox("Change card 2");
		changeCard1.setBounds(764, 38, 113, 25);
		tableCenter.add(changeCard1);
		
		changeCard2 = new JCheckBox("Change card 3");
		changeCard2.setBounds(764, 68, 113, 25);
		tableCenter.add(changeCard2);
		
		changeCard3 = new JCheckBox("Change card 4");
		changeCard3.setBounds(764, 98, 113, 25);
		tableCenter.add(changeCard3);
		
		playersBottom = new JPanel();
		table.add(playersBottom);
		playersBottom.setLayout(new GridLayout(1, 3, 0, 0));
		
		player2 = new JPanel();
		player2.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		playersBottom.add(player2);
		player2.setLayout(null);
		
		player2Status = new JLabel("IsDealer/SmallBlind/BigBlind");
		player2Status.setBounds(12, 0, 283, 29);
		player2.add(player2Status);
		
		player2Bet = new JLabel("Current bet: $0.00");
		player2Bet.setHorizontalAlignment(SwingConstants.LEFT);
		player2Bet.setBounds(12, 124, 135, 29);
		player2.add(player2Bet);
		
		player2Cards = new JPanel();
		player2Cards.setBounds(10, 29, 273, 96);
		player2.add(player2Cards);
		player2Cards.setLayout(new GridLayout(1, 4, 0, 0));
		
		player2Card1 = new JLabel("First Card");
		player2Cards.add(player2Card1);
		
		player2Card2 = new JLabel("Second Card");
		player2Cards.add(player2Card2);
		
		player2Card3 = new JLabel("Third Card");
		player2Cards.add(player2Card3);
		
		player2Card4 = new JLabel("Fourth Card");
		player2Cards.add(player2Card4);
		
		player2Balance = new JLabel("Balance: $0.00");
		player2Balance.setHorizontalAlignment(SwingConstants.RIGHT);
		player2Balance.setBounds(138, 124, 145, 29);
		player2.add(player2Balance);
		
		player1 = new JPanel();
		player1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		playersBottom.add(player1);
		player1.setLayout(null);
		
		player1Status = new JLabel("IsDealer/SmallBlind/BigBlind");
		player1Status.setBounds(12, 0, 283, 29);
		player1.add(player1Status);
		
		player1Bet = new JLabel("Current bet: $0.00");
		player1Bet.setBounds(12, 124, 136, 29);
		player1.add(player1Bet);
		
		player1Cards = new JPanel();
		player1Cards.setBounds(10, 30, 273, 97);
		player1.add(player1Cards);
		player1Cards.setLayout(new GridLayout(1, 4, 0, 0));
		
		player1Card1 = new JLabel("First Card");
		player1Cards.add(player1Card1);
		
		player1Card2 = new JLabel("Second Card");
		player1Cards.add(player1Card2);
		
		player1Card3 = new JLabel("Third Card");
		player1Cards.add(player1Card3);
		
		player1Card4 = new JLabel("Fourth Card");
		player1Cards.add(player1Card4);
		
		player1Balance = new JLabel("Balance: $0.00");
		player1Balance.setHorizontalAlignment(SwingConstants.RIGHT);
		player1Balance.setBounds(140, 127, 143, 23);
		player1.add(player1Balance);
		
		player6 = new JPanel();
		player6.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		playersBottom.add(player6);
		player6.setLayout(null);
		
		player6Status = new JLabel("IsDealer/SmallBlind/BigBlind");
		player6Status.setBounds(12, 0, 283, 29);
		player6.add(player6Status);
		
		player6Bet = new JLabel("Current bet: $0.00");
		player6Bet.setBounds(12, 124, 136, 29);
		player6.add(player6Bet);
		
		player6Cards = new JPanel();
		player6Cards.setBounds(10, 30, 273, 97);
		player6.add(player6Cards);
		player6Cards.setLayout(new GridLayout(1, 4, 0, 0));
		
		player6Card1 = new JLabel("First Card");
		player6Cards.add(player6Card1);
		
		player6Card2 = new JLabel("Secon Card");
		player6Cards.add(player6Card2);
		
		player6Card3 = new JLabel("Third Card");
		player6Cards.add(player6Card3);
		
		player6Card4 = new JLabel("Fourth Card");
		player6Cards.add(player6Card4);
		
		player6Balance = new JLabel("Balance: $0.00");
		player6Balance.setHorizontalAlignment(SwingConstants.RIGHT);
		player6Balance.setBounds(143, 127, 140, 23);
		player6.add(player6Balance);
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setBounds(0, 0, 897, 26);
		mainPanel.add(menuBar);
		
		JMenu game = new JMenu("Game");
		menuBar.add(game);
		
		JMenuItem mntmStartGame = new JMenuItem("Start game");
		mntmStartGame.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Client.clientThread.getOutput().println( "S" );
			}
			
		});
		game.add(mntmStartGame);
		
		JMenuItem mntmGameRules = new JMenuItem("Game rules");
		game.add(mntmGameRules);
		
		JMenuItem mntmExit = new JMenuItem("Exit");
		mntmExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
			}
		});
		game.add(mntmExit);
		
		JMenu mnOptions = new JMenu("Options");
		menuBar.add(mnOptions);
		
		JCheckBoxMenuItem chckbxmntmChangeColors = new JCheckBoxMenuItem("Change colors");
		mnOptions.add(chckbxmntmChangeColors);
		
		JMenu mnHelp = new JMenu("Help");
		menuBar.add(mnHelp);
		
		JMenuItem mntmAbout = new JMenuItem("About");
		mnHelp.add(mntmAbout);
		
		bidTimeOver();
		changeCardsTimeOver();
		
	}
	public JPanel getPlayer1() {
		return player1;
	}
	public JPanel getPlayer3() {
		return player3;
	}
	public JLabel getPlayer3Status() {
		return player3Status;
	}
	public JLabel getPlayer3Bet() {
		return player3Bet;
	}
	public JLabel getPlayer3Balance() {
		return player3Balance;
	}
	public JPanel getPlayer3Cards() {
		return player3Cards;
	}
	public JLabel getPlayer3Card1() {
		return player3card1;
	}
	public JLabel getPlayer3Card2() {
		return player3card2;
	}
	public JLabel getPlayer3Card3() {
		return player3card3;
	}
	public JLabel getPlayer3Card4() {
		return player3card4;
	}
	public JPanel getPlayer4() {
		return player4;
	}
	public JLabel getPlayer4Status() {
		return player4Status;
	}
	public JLabel getPlayer4Bet() {
		return player4Bet;
	}
	public JPanel getPlayer4Cards() {
		return player4Cards;
	}
	public JLabel getPlayer4Card1() {
		return player4Card1;
	}
	public JLabel getPlayer4Card2() {
		return player4Card2;
	}
	public JLabel getPlayer4Card3() {
		return player4Card3;
	}
	public JLabel getPlayer4Card4() {
		return player4Card4;
	}
	public JLabel getPlayer4Balance() {
		return player4Balance;
	}
	public JPanel getPlayer5() {
		return player5;
	}
	public JLabel getPlayer5Status() {
		return player5Status;
	}
	public JLabel getPlayer5Bet() {
		return player5Bet;
	}
	public JPanel getPlayer5Cards() {
		return player5Cards;
	}
	public JLabel getPlayer5Card1() {
		return player5Card1;
	}
	public JLabel getPlayer5Card2() {
		return player5Card2;
	}
	public JLabel getPlayer5Card3() {
		return player5Card3;
	}
	public JLabel getPlayer5Card4() {
		return player5Card4;
	}
	public JLabel getPlayer5Balance() {
		return player5Balance;
	}
	public JPanel getTableCenter() {
		return tableCenter;
	}
	public JLabel getSmallBlindValue() {
		return smallBlindValue;
	}
	public JLabel getBigBlindValue() {
		return bigBlindValue;
	}
	public JLabel getStartingBalanceValue() {
		return startingBalanceValue;
	}
	public JLabel getLastWinnerName() {
		return lastWinnerName;
	}
	public JEditorPane getLog() {
		return log;
	}
	public JPanel getPlayersBottom() {
		return playersBottom;
	}
	public JPanel getPlayer2() {
		return player2;
	}
	public JLabel getPlayer2Status() {
		return player2Status;
	}
	public JLabel getPlayer2Bet() {
		return player2Bet;
	}
	public JPanel getPlayer2Cards() {
		return player2Cards;
	}
	public JLabel getPlayer2Card1() {
		return player2Card1;
	}
	public JLabel getPlayer2Card2() {
		return player2Card2;
	}
	public JLabel getPlayer2Card3() {
		return player2Card3;
	}
	public JLabel getPlayer2Card4() {
		return player2Card4;
	}
	public JLabel getPlayer2Balance() {
		return player2Balance;
	}
	public JLabel getPlayer1Status() {
		return player1Status;
	}
	public JLabel getPlayer1Bet() {
		return player1Bet;
	}
	public JPanel getPlayer1Cards() {
		return player1Cards;
	}
	public JLabel getPlayer1Card1() {
		return player1Card1;
	}
	public JLabel getPlayer1Card2() {
		return player1Card2;
	}
	public JLabel getPlayer1Card3() {
		return player1Card3;
	}
	public JLabel getPlayer1Card4() {
		return player1Card4;
	}
	public JLabel getPlayer1Balance() {
		return player1Balance;
	}
	public JPanel getPlayer6() {
		return player6;
	}
	public JLabel getPlayer6Status() {
		return player6Status;
	}
	public JLabel getPlayer6Bet() {
		return player6Bet;
	}
	public JPanel getPlayer6Cards() {
		return player6Cards;
	}
	public JLabel getPlayer6Card1() {
		return player6Card1;
	}
	public JLabel getPlayer6Card2() {
		return player6Card2;
	}
	public JLabel getPlayer6Card3() {
		return player6Card3;
	}
	public JLabel getPlayer6Card4() {
		return player6Card4;
	}
	public JLabel getPlayer6Balance() {
		return player6Balance;
	}
	public JButton getFoldJButton() {
		return foldJButton;
	}
	public JButton getCheckJButton() {
		return checkJButton;
	}
	public JButton getCallJButton() {
		return callJButton;
	}
	public JButton getRaiseJButton() {
		return raiseJButton;
	}
	public JButton getAllInJButton() {
		return allInJButton;
	}
	public JButton getZeroBetJButton() {
		return zeroBetJButton;
	}
	public JButton getFirstBetJButton() {
		return firstBetJButton;
	}
	public JButton getSecondBetJButton() {
		return secondBetJButton;
	}
	public JButton getThirdBetJButton() {
		return thirdBetJButton;
	}
	public JButton getChangeCards() {
		return changeCards;
	}
	public JLabel getUserBalance() {
		return userBalance;
	}
	public JLabel getTotalPot() {
		return totalPot;
	}
	public JLabel getRaiseAmount() {
		return raiseAmount;
	}
	public JLabel getShortInformationFromServer() {
		return shortInformationFromServer;
	}
	public JLabel getYourBet() {
		return yourBet;
	}
	/**
	 * Method that places player on a certain slot in GUI
	 * @param slot
	 */
	public void sitDown(int slot){
		switch (slot){
			case 0:
				player1.setBackground(Color.GREEN);
				player1Status.setBackground(Color.GREEN);
				player1Balance.setBackground(Color.GREEN);
				player1Bet.setBackground(Color.GREEN);
				break;
			case 1:
				player2.setBackground(Color.GREEN);
				player2Status.setBackground(Color.GREEN);
				player2Balance.setBackground(Color.GREEN);
				player2Bet.setBackground(Color.GREEN);
				break;
			case 2:
				player3.setBackground(Color.GREEN);
				player3Status.setBackground(Color.GREEN);
				player3Balance.setBackground(Color.GREEN);
				player3Bet.setBackground(Color.GREEN);
				break;
			case 3:
				player4.setBackground(Color.GREEN);
				player4Status.setBackground(Color.GREEN);
				player4Balance.setBackground(Color.GREEN);
				player4Bet.setBackground(Color.GREEN);
				break;
			case 4:
				player5.setBackground(Color.GREEN);
				player5Status.setBackground(Color.GREEN);
				player5Balance.setBackground(Color.GREEN);
				player5Bet.setBackground(Color.GREEN);
				break;
			case 5:
				player6.setBackground(Color.GREEN);
				player6Status.setBackground(Color.GREEN);
				player6Balance.setBackground(Color.GREEN);
				player6Bet.setBackground(Color.GREEN);
				break;
		}
		this.slot = slot;
	}
	public void bidTime(String news){
		if (news.charAt(0) == '1'){
			foldJButton.setEnabled(true);
		}
		if (news.charAt(1) == '1'){
				checkJButton.setEnabled(true);
		}
		if (news.charAt(2) == '1'){
			callJButton.setEnabled(true);
		}
		if (news.charAt(3) == '1'){
			raiseJButton.setEnabled(true);
		}
		if (news.charAt(4) == '1'){
			allInJButton.setEnabled(true);
		}
		zeroBetJButton.setEnabled(true);
		firstBetJButton.setEnabled(true);
		secondBetJButton.setEnabled(true);
		thirdBetJButton.setEnabled(true);
	}
	/**
	 * Called after actionPerformed on any bet button
	 */
	public void bidTimeOver(){
		foldJButton.setEnabled(false);
		checkJButton.setEnabled(false);
		callJButton.setEnabled(false);
		raiseJButton.setEnabled(false);
		allInJButton.setEnabled(false);
		zeroBetJButton.setEnabled(false);
		firstBetJButton.setEnabled(false);
		secondBetJButton.setEnabled(false);
		thirdBetJButton.setEnabled(false);
	}
	public void changeCardsTime(){
		changeCards.setEnabled(true);
	}
	/**
	 * Called after actionPerformed on changeCards
	 */
	public void changeCardsTimeOver(){
		changeCards.setEnabled(false);
		changeCard0.setSelected(false);
		changeCard1.setSelected(false);
		changeCard2.setSelected(false);
		changeCard3.setSelected(false);
	}
	public void someonesMove(int id, boolean changingCards, int cards, char action, int bid, int balance){
		if (changingCards && cards > 0){
			switch (id){
			case 0:
				getPlayer1Status().setText(cards + " cards changed");
				break;
			case 1:
 				getPlayer2Status().setText(cards + " cards changed");
				break;
			case 2:
				getPlayer3Status().setText(cards + " cards changed");
				break;
			case 3:
				getPlayer4Status().setText(cards + " cards changed");
				break;
			case 4:
				getPlayer5Status().setText(cards + " cards changed");
				break;
			case 5:
				getPlayer6Status().setText(cards + " cards changed");
				break;
			}
		}
		else if (changingCards){
			switch (id){
			case 0:
				getPlayer1Status().setText("No cards changed");
				break;
			case 1:
 				getPlayer2Status().setText("No cards changed");
				break;
			case 2:
				getPlayer3Status().setText("No cards changed");
				break;
			case 3:
				getPlayer4Status().setText("No cards changed");
				break;
			case 4:
				getPlayer5Status().setText("No cards changed");
				break;
			case 5:
				getPlayer6Status().setText("No cards changed");
				break;
			}
		}
		
		else{
			if (slot == id){
				this.balance = balance;
				getUserBalance().setText("Cash: $" + balance);
			}
			switch (id){
			case 0:
				getPlayer1Balance().setText("Balance: $" + balance);
				getPlayer1Bet().setText("Bet: $"+bid);
				if(action != 'F'){
					getPlayer1Status().setText("Still in-game");
				}else{
					getPlayer1Status().setText("Folded");
				}
				break;
			case 1:
				getPlayer2Balance().setText("Balance: $" + balance);
				getPlayer2Bet().setText("Bet: $"+bid);
				if(action != 'F'){
					getPlayer2Status().setText("Still in-game");
				}else{
					getPlayer2Status().setText("Folded");
				}
				break;
			case 2:
				getPlayer3Balance().setText("Balance: $" + balance);
				getPlayer3Bet().setText("Bet: $"+bid);
				if(action != 'F'){
					getPlayer3Status().setText("Still in-game");
				}else{
					getPlayer3Status().setText("Folded");
				}
				break;
			case 3:
				getPlayer4Balance().setText("Balance: $" + balance);
				getPlayer4Bet().setText("Bet: $"+bid);
				if(action != 'F'){
					getPlayer4Status().setText("Still in-game");
				}else{
					getPlayer4Status().setText("Folded");
				}
				break;
			case 4:
				getPlayer5Balance().setText("Balance: $" + balance);
				getPlayer5Bet().setText("Bet: $"+bid);
				if(action != 'F'){
					getPlayer5Status().setText("Still in-game");
				}else{
					getPlayer5Status().setText("Folded");
				}
				break;
			case 5:
				getPlayer6Balance().setText("Balance: $" + balance);
				getPlayer6Bet().setText("Bet: $"+bid);
				if(action != 'F'){
					getPlayer6Status().setText("Still in-game");
				}else{
					getPlayer6Status().setText("Folded");
				}
				break;
			}
		}
	}
	public void winners(int id, int won, int balance) {
		if (this.slot == id){
			this.balance = balance;
			getUserBalance().setText("Cash: $" + balance);
		}
		switch (id){
		case 0:
			getPlayer1Balance().setText("Balance: $" + balance);
			getPlayer1Status().setText("Won " + won);
			break;
		case 1:
			getPlayer2Balance().setText("Balance: $" + balance);
			getPlayer2Status().setText("Won " + won);
			break;
		case 2:
			getPlayer3Balance().setText("Balance: $" + balance);
			getPlayer3Status().setText("Won " + won);
			break;
		case 3:
			getPlayer4Balance().setText("Balance: $" + balance);
			getPlayer4Status().setText("Won " + won);
			break;
		case 4:
			getPlayer5Balance().setText("Balance: $" + balance);
			getPlayer5Status().setText("Won " + won);
			break;
		case 5:
			getPlayer6Balance().setText("Balance: $" + balance);
			getPlayer6Status().setText("Won " + won);
			break;
		}
	}
	public void setup(int id, String status, int bid, int balance){
		if (slot == id){
			this.balance = balance;
			getUserBalance().setText("Cash: $" + balance);
		}
		switch (id){
		case 0:
			getPlayer1Balance().setText("Balance: $" + balance);
			getPlayer1Bet().setText("Bet: $" + bid);
			if (status.toLowerCase() != "custom"){
				getPlayer1Status().setText(status);
			}
			break;
		case 1:
			getPlayer2Balance().setText("Balance: $" + balance);
			getPlayer2Bet().setText("Bet: $" + bid);
			if (status.toLowerCase() != "custom"){
				getPlayer2Status().setText(status);
			}
			break;
		case 2:
			getPlayer3Balance().setText("Balance: $" + balance);
			getPlayer3Bet().setText("Bet: $" + bid);
			if (status.toLowerCase() != "custom"){
				getPlayer3Status().setText(status);
			}
			break;
		case 3:
			getPlayer4Balance().setText("Balance: $" + balance);
			getPlayer4Bet().setText("Bet: $" + bid);
			if (status.toLowerCase() != "custom"){
				getPlayer4Status().setText(status);
			}
			break;
		case 4:
			getPlayer5Balance().setText("Balance: $" + balance);
			getPlayer5Bet().setText("Bet: $" + bid);
			if (status.toLowerCase() != "custom"){
				getPlayer5Status().setText(status);
			}
			break;
		case 5:
			getPlayer6Balance().setText("Balance: $" + balance);
			getPlayer6Bet().setText("Bet: $" + bid);
			if (status.toLowerCase() != "custom"){
				getPlayer6Status().setText(status);
			}
			break;
		}
		getPlayer1Card1().setText("");
		getPlayer1Card2().setText("");
		getPlayer1Card3().setText("");
		getPlayer1Card4().setText("");
		getPlayer2Card1().setText("");
		getPlayer2Card2().setText("");
		getPlayer2Card3().setText("");
		getPlayer2Card4().setText("");
		getPlayer3Card1().setText("");
		getPlayer3Card2().setText("");
		getPlayer3Card3().setText("");
		getPlayer3Card4().setText("");
		getPlayer4Card1().setText("");
		getPlayer4Card2().setText("");
		getPlayer4Card3().setText("");
		getPlayer4Card4().setText("");
		getPlayer5Card1().setText("");
		getPlayer5Card2().setText("");
		getPlayer5Card3().setText("");
		getPlayer5Card4().setText("");
		getPlayer6Card1().setText("");
		getPlayer6Card2().setText("");
		getPlayer6Card3().setText("");
		getPlayer6Card4().setText("");
		
		
	}
	public void cards(int id, String rank1, String suit1, String rank2, String suit2, String rank3, String suit3, String rank4, String suit4){
		switch (id){
		case 0:
			getPlayer1Card1().setText(rank1 + suit1.substring(0, 1));
			getPlayer1Card2().setText(rank2 + suit2.substring(0, 1));
			getPlayer1Card3().setText(rank3 + suit3.substring(0, 1));
			getPlayer1Card4().setText(rank4 + suit4.substring(0, 1));
			break;
		case 1:
			getPlayer2Card1().setText(rank1 + suit1.substring(0, 1));
			getPlayer2Card2().setText(rank2 + suit2.substring(0, 1));
			getPlayer2Card3().setText(rank3 + suit3.substring(0, 1));
			getPlayer2Card4().setText(rank4 + suit4.substring(0, 1));
			break;
		case 2:
			getPlayer3Card1().setText(rank1 + suit1.substring(0, 1));
			getPlayer3Card2().setText(rank2 + suit2.substring(0, 1));
			getPlayer3Card3().setText(rank3 + suit3.substring(0, 1));
			getPlayer3Card4().setText(rank4 + suit4.substring(0, 1));
			break;
		case 3:
			getPlayer4Card1().setText(rank1 + suit1.substring(0, 1));
			getPlayer4Card2().setText(rank2 + suit2.substring(0, 1));
			getPlayer4Card3().setText(rank3 + suit3.substring(0, 1));
			getPlayer4Card4().setText(rank4 + suit4.substring(0, 1));
			break;
		case 4:
			getPlayer5Card1().setText(rank1 + suit1.substring(0, 1));
			getPlayer5Card2().setText(rank2 + suit2.substring(0, 1));
			getPlayer5Card3().setText(rank3 + suit3.substring(0, 1));
			getPlayer5Card4().setText(rank4 + suit4.substring(0, 1));
			break;
		case 5:
			getPlayer6Card1().setText(rank1 + suit1.substring(0, 1));
			getPlayer6Card2().setText(rank2 + suit2.substring(0, 1));
			getPlayer6Card3().setText(rank3 + suit3.substring(0, 1));
			getPlayer6Card4().setText(rank4 + suit4.substring(0, 1));
			break;
		}
	}
	public void newgame(int sb, int bb, int balance){
		getSmallBlindValue().setText("Small blind: $" + sb);
		getBigBlindValue().setText("Big blind: $" + bb);
		getStartingBalanceValue().setText("Starting money: $" + balance);
		getUserBalance().setText("Cash: $" + balance);
		this.balance = balance;
	}
}